﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Common;

namespace Ym.print
{
    public partial class ShowEdit : PrintPageBase
    {
        private PBLL.PShow bll = new PBLL.PShow();
        private string id = "0";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                if (string.IsNullOrEmpty((string)Session["UserName"]))
                {

                }
                if (!string.IsNullOrEmpty(Request.QueryString["id"]))
                {
                    id = Request.QueryString["id"].ToString();
                    PModel.PShow model = bll.GetModel(id);
                    Text1.Value = model.SName;
                    pUrl.Text = model.SPic;
                    ne.InnerText = "修改印品展示";
                }
                else
                {
                    ne.InnerText = "添加印品展示";
                }
                Hidden1.Value = id;
            }
        }

        protected void save_Click(object sender, EventArgs e)
        {
            PModel.PShow model = new PModel.PShow();

            model.SName = Text1.Value; ;
            model.SPic = pUrl.Text;
            if (Hidden1.Value == "0")
            {
                bll.Insert(model);
                JscriptPrint("添加成功！", "Show.aspx", "Success");
            }
            else
            {
                model.Id = int.Parse(Hidden1.Value);
                bll.Update(model);
                JscriptPrint("修改成功！", "Show.aspx", "Success");
            }
        }
    }
}